import request from '@/utils/request';
import type { BaseBeanModel, ResponsePageData, ResponseBaseData, QueryParamModel } from '@/api/model/baseModel';
import type { downloadParam } from '@/utils/download-util';
import { downloadSysFile } from '@/utils/download-util';
const basePath = '/appsys/position/PositionRest';
/** 岗位表 */
export type SysPositionDto = BaseBeanModel;

/**
 * 获取分页数据
 * @param param 分页查询条件
 * @returns 获取分页数据
 */
export function listSysPositionByPage(param: QueryParamModel): Promise<ResponsePageData<SysPositionDto>> {
  return request.post(`${basePath}/searchByPage/v1`, param);
}
/**
 * 查询用户列表
 * @param queryParam 子表分页查询条件
 * @param mainId 主表id
 * @returns 子表分页数据
 */
export function listSysUserByPage(queryParam, mainId) {
  return request.post(`/appsys/position/PositionRest/searchSysUserByPage/${mainId.value}/v1`, queryParam);
}
/**
 * 保存表单数据
 * @param form 主表数据
 * @returns 获取分页数据
 */
export function saveSysPosition(form: [SysPositionDto]): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/savePositions/v1`, form);
}
/**
 * 根据id集合删除数据
 * @param ids 输出id集合
 * @returns 获取分页数据
 */
export function delSysPosition(ids: [string]): Promise<ResponseBaseData<any>> {
  return request.delete(`${basePath}/deleteByIds/v1`, { data: ids });
}
/**
 * 导出Excel
 * @param ids 导出id数组
 * @returns 导出结果
 */
export function exportExcel(param: object) {
  const download = {
    url: `${basePath}/exportServerData/v1`,
    data: param,
    method: 'post'
  } as downloadParam;
  return downloadSysFile(download);
}
/**
 * 获取添加用户数据
 * @param record 添加的用户数据
 * @returns 添加接口的返回结果
 */
export function addSysPosition(record: object): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/getUserInsertParam/v1`, record);
}

/**
 * 批量保存用户数据
 * @param mainId 主键id
 * @param list 选中的列表数据
 * @returns 返回添加结果
 */
export function saveAllSysPosition(mainId, list) {
  return request.post(`${basePath}/savePositionUser/${mainId.value}/v1`, list);
}

/**
 * 批量保存用户数据
 * @param list 删除列表
 * @returns 返回删除结果
 */
export function deletePositionUser(list) {
  return request.delete(`${basePath}/deletePositionUser/v1`, { data: list });
}
